package com.cwvs.cat.adapter;

import java.util.List;

import com.cwvs.cat.R;
import com.cwvs.cat.bean.Order;
import com.cwvs.cat.bean.OrderItem;
import com.cwvs.cat.bean.OrderShopInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class OrderLvAdapter extends BaseAdapter {
	
	private Context context;
	
	private List<Order> list;
	
	private LayoutInflater mInflater;
	
	public OrderLvAdapter(Context context, List<Order> list) {
		this.context = context;
		this.list = list;
		this.mInflater = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.listview_order_item, null);
			holder = new ViewHolder();
			holder.tvName = (TextView) convertView.findViewById(R.id.tvName);
			holder.tvOrderStatus = (TextView) convertView.findViewById(R.id.tvOrderStatus);
			holder.lv = (ListView) convertView.findViewById(R.id.lv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		
		Order order = list.get(position);
		List<OrderItem> orderItems = order.getOrder_items();
		OrderShopInfo shopInfo = order.getShop_info();
		
		holder.tvName.setText(shopInfo.getShop_name());
		
		return convertView;
	}
	
	public class ViewHolder {
		private TextView tvName, tvOrderStatus;
		private ListView lv;
	}

}
